package com.tbit.main.service.impl;

import com.tbit.main.constant.DaoParamConstant;
import com.tbit.main.dao.core.MachineNoIncomeDao;
import com.tbit.main.pojo.MachineNoIncome;
import com.tbit.main.pojo.MachineStatus;
import com.tbit.main.service.MachineNoIncomeService;
import com.tbit.main.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author LMY
 * @create 2021-09-01 15:21
 */
@Service("machineNoIncomeService")
public class MachineNoIncomeServiceImpl implements MachineNoIncomeService {

    @Autowired
    private MachineNoIncomeDao machineNoIncomeDao;

    @Override
    public List<MachineNoIncome> getByUserCode(String userCode, Integer accountId) {
        Map<String, Object> map = new HashMap<>();
        map.put("userCode", userCode);
        map.put(DaoParamConstant.accountId, accountId);
        return machineNoIncomeDao.getByUserCode(map);
    }

    @Override
    public List<MachineStatus> getByAccountIdAndCount(Integer accountId, Integer count) {
        Map<String, Object> map = new HashMap<>();
        map.put(DaoParamConstant.accountId, accountId);
        map.put("count", count);
        return machineNoIncomeDao.getByAccountIdAndCount(map);
    }

    @Override
    public List<MachineStatus> getByRegionIdAndCount(List<Integer> regionId, Integer count) {
        Map<String, Object> map = new HashMap<>();
        map.put("regionId", StringUtil.getListString(regionId));
        map.put("count", count);
        return machineNoIncomeDao.getByRegionIdAndCount(map);
    }

    @Override
    public void insert(MachineNoIncome machineNoIncome) {
        machineNoIncomeDao.insert(machineNoIncome);
    }

    @Override
    public void del(String userCode, Integer accountId) {
        Map<String, Object> map = new HashMap<>();
        map.put("userCode", userCode);
        map.put(DaoParamConstant.accountId, accountId);
        machineNoIncomeDao.del(map);
    }

    @Override
    public List<Integer> getExist(List<Integer> list) {
        return machineNoIncomeDao.getExist(list);
    }

    @Override
    public void deleteBatchByMachineList(List<String> userCodeList) {
        machineNoIncomeDao.deleteBatchByMachineList(userCodeList);
    }
}
